package view;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;

import controller.menubar.QuitListener;
import controller.menubar.commands.Copy;
import controller.menubar.commands.Delete;
import controller.menubar.commands.MkDir;
import controller.menubar.commands.Move;
import controller.menubar.commands.Rename;

import model.GlobalParams;

public class HotKeysBar extends JPanel {
	
	private static final long serialVersionUID = 1L;
	
	public HotKeysBar(MainFrame f) {
		
		frame = f;
		
		btn_hotKeys_view = new JButton();
		btn_hotKeys_edit = new JButton();
		btn_hotKeys_copy = new JButton();
		btn_hotKeys_move = new JButton();
		btn_hotKeys_newfolder = new JButton();
		btn_hotKeys_delete = new JButton();
		btn_hotKeys_exit = new JButton();	
		
		updateNames();		
		GridBagConstraints cc = new GridBagConstraints();		
		setLayout(new GridBagLayout());
		
		cc.fill = GridBagConstraints.HORIZONTAL;          
        cc.gridx = 0;
        cc.gridy = 0;
        cc.weightx = 0.20;            
        add(btn_hotKeys_copy,cc); 
        add(new JSeparator(SwingConstants.VERTICAL));        
      
        cc.gridx = 1;
        cc.gridy = 0;
        cc.weightx = 0.20;      
        add(btn_hotKeys_move,cc);
        add(new JSeparator(SwingConstants.VERTICAL));        
        
        cc.gridx = 2;
        cc.gridy = 0;
        cc.weightx = 0.20;          
        add(btn_hotKeys_newfolder,cc); 
        add(new JSeparator(SwingConstants.VERTICAL));        
        
        cc.gridx = 3;
        cc.gridy = 0;
        cc.weightx = 0.20;        
        add(btn_hotKeys_delete,cc);
        add(new JSeparator(SwingConstants.VERTICAL));       
        
        cc.gridx = 4;
        cc.gridy = 0;
        cc.weightx = 0.20;        
        add(btn_hotKeys_edit,cc);
        add(new JSeparator(SwingConstants.VERTICAL));         
           
        cc.gridx = 5;
        cc.gridy = 0;
        cc.weightx = 0.20;         
        add(btn_hotKeys_exit,cc);
        
        btn_hotKeys_edit.addActionListener(new Rename(frame));
        btn_hotKeys_copy.addActionListener(new Copy(frame));
		btn_hotKeys_move.addActionListener(new Move(frame));
		btn_hotKeys_newfolder.addActionListener(new MkDir(frame));
		btn_hotKeys_delete.addActionListener(new Delete(frame));
		btn_hotKeys_exit.addActionListener(new QuitListener(frame));
	}
	
	public void updateNames() {		
		btn_hotKeys_view.setText(GlobalParams.getInstance().stringCollection.getBtn_hotKeys_view());
		btn_hotKeys_edit.setText(GlobalParams.getInstance().stringCollection.getBtn_hotKeys_edit());
		btn_hotKeys_copy.setText(GlobalParams.getInstance().stringCollection.getBtn_hotKeys_copy());
		btn_hotKeys_move.setText(GlobalParams.getInstance().stringCollection.getBtn_hotKeys_move());
		btn_hotKeys_newfolder.setText(GlobalParams.getInstance().stringCollection.getBtn_hotKeys_newfolder());
		btn_hotKeys_delete.setText(GlobalParams.getInstance().stringCollection.getBtn_hotKeys_delete());
		btn_hotKeys_exit.setText(GlobalParams.getInstance().stringCollection.getBtn_hotKeys_exit());		
	}
	
	public void disableDelete() {btn_hotKeys_delete.setEnabled(false);}
	public void enableDelete() {btn_hotKeys_delete.setEnabled(true);}
	
	public void disableCopy() {btn_hotKeys_copy.setEnabled(false);}
	public void enableCopy() {btn_hotKeys_copy.setEnabled(true);}
	
	public void disableMove() {btn_hotKeys_move.setEnabled(false);}
	public void enableMove() {btn_hotKeys_move.setEnabled(true);}
	
	public void disableNewFolder() {btn_hotKeys_newfolder.setEnabled(false);}
	public void enableNewFolder() {btn_hotKeys_newfolder.setEnabled(true);}
	
	private MainFrame frame;	
	private JButton btn_hotKeys_view;
	private JButton btn_hotKeys_edit;
	private JButton btn_hotKeys_copy;
	private JButton btn_hotKeys_move;
	private JButton btn_hotKeys_newfolder;
	private JButton btn_hotKeys_delete;
	private JButton btn_hotKeys_exit;

}
